package com.example.love_margin.Service.Impl;


import com.example.love_margin.Entity.Sale;
import com.example.love_margin.Mapper.SaleMapper;
import com.example.love_margin.Service.SaleService;
import com.example.love_margin.Untils.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SaleServiceImpl implements SaleService {

    @Autowired
    SaleMapper saleMapper;

    @Override
    public Object addSale(Sale sale) {
        if(saleMapper.addSale(sale)==1){
            return ResultCode.SUCCESS.result("增加成功");
        }
        return ResultCode.SUCCESS.result("增加失败");
    }

    @Override
    public Object deleteSale(int sale_id) {
        if(saleMapper.deleteSale(sale_id)==1){
            return ResultCode.SUCCESS.result("增加成功");
        }
        return ResultCode.SUCCESS.result("增加失败");
    }

    @Override
    public Object selectOne(int sale_id) {
        return ResultCode.SUCCESS.result(saleMapper.selectOneSale(sale_id));
    }

    @Override
    public Object selectAll() {
        return ResultCode.SUCCESS.result(saleMapper.selectAll());
    }

    @Override
    public Object upSale(Sale sale) {
        if(saleMapper.upSale(sale)==1){
            return ResultCode.SUCCESS.result("修改成功");
        }
        return ResultCode.SUCCESS.result("修改失败");
    }
}
